package com.globalblue;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.globalblue.services.ServiceFileDownloader;

/**
 * Servlet implementation class FileDownloadController
 */
@WebServlet("/FileDownloadController")
public class FileDownloadController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final Logger logger = Logger.getLogger(FileDownloadController.class);

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public FileDownloadController() {
		super();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			ServiceFileDownloader downloader = new ServiceFileDownloader();
			downloader.downloadFiles(downloader.getUpdatedServerIpList());
		} catch (Exception e) {
			logger.log(Level.ERROR, e);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
